import chalk from 'chalk'
import getEnv from './getEnv'
export default function () {
  return {
    name: 'printLogo',
    apply: 'serve',
    enforce: 'pre',
    configureServer(server) {
      const print = server.printUrls
      server.printUrls = () => {
        const currentEnv = getEnv()
        const configInfo = require(`../config/${currentEnv}.env.cjs`)
        console.log(`  ${chalk.blue.dim('➜')}  ${chalk.blue.dim.bold('NODE_ENV：')} ${chalk.blue.dim(currentEnv)}`)
        console.log(
          `  ${chalk.blue.dim('➜')}  ${chalk.blue.dim.bold('API_URL：')} ${chalk.blue.dim(configInfo.API_URL)}`
        )
        print()
      }
    },
  }
}
